home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / COM / ProTERM Mac1.2a.sit / ProTERM Mac1.2a / Macros / Resident Library 1201 < prev    next >
Text File  |  1996-08-03  |  5KB  |  199 lines

  1. /****************************************
  2.  *                                      *
  3.  *  ProTERM/Mac Resident Macro Library  *
  4.  *                                      *
  5.  *   Version 1201  Updated 07/18/96     *
  6.  *                                      *
  7.  ****************************************/
  8.  
  9. /*
  10. This file is periodically updated by InTrec Software. As such, modifications to this file are not advised (because it becomes very difficult to move your changes to new versions of this file). Instead, make your changes to the Resident User # (where # is a number) file instead. That way, even if you get an updated version of Resident Library, your own personal macros remain unchanged within the Resident User # file.
  11.  
  12. The Resident User # files have precedence over the Resident Library file. Therefore, if you define duplicate routines or variables in the Resident User # files, they will be used instead of those in the Resident Library file.
  13. */
  14.  
  15. // special code to allow direct execution
  16. FUNC main()
  17. {
  18.  EXTERN(PREF_GET("mac1"),main(1));
  19.  RETURN;
  20. }
  21.  
  22. // make the library resident
  23. FUNC startup()
  24. {
  25.  SHARED STR _RLIB = "1022";
  26.  RESIDENT("",0,#KeyAccess+#LibAccess);
  27.  RETURN;
  28. }
  29.  
  30.  
  31. /***********************************************************************/
  32. /*                   Start of Library Macros                           */
  33. /***********************************************************************/
  34.  
  35. /*
  36. cmd_find(win_active(0),"resu^clt",0,0,0);
  37. */
  38.  
  39.  
  40. // find text
  41. FUNC cmd_find(INT win, STR find, INT from, INT uppr, INT dirc)
  42. {
  43.  STR result,from0,uppr0,dirc0;
  44.  
  45.  from0 = "start";
  46.  IF (from == 1) { from0 = "curs" }
  47.  uppr0 = "ignore";
  48.  IF (uppr == 1) { uppr0 = "exact" }
  49.  dirc0 = "forward";
  50.  IF (dirc == 1) { dirc0 = "reverse" }
  51.  
  52.  result = UI_CMD('^
  53.   cmd=find wind=%d find=&%*2s from=%s case=%s dir=%s
  54.  ',win,find,from0,uppr0,dirc0);
  55.  RETURN(UI_NUM("retn",0,result))
  56. }
  57.  
  58.  
  59. // replace text
  60. FUNC cmd_replace(INT win, STR find, STR repl, INT from, INT uppr, INT dirc)
  61. {
  62.  STR result,from0,uppr0,dirc0;
  63.  
  64.  from0 = "start";
  65.  IF (from == 1) { from0 = "curs" }
  66.  uppr0 = "ignore";
  67.  IF (uppr == 1) { uppr0 = "exact" }
  68.  dirc0 = "forward";
  69.  IF (dirc == 1) { dirc0 = "reverse" }
  70.  
  71.  result = UI_CMD('^
  72.   cmd=find wind=%d find=&%*2s repl=&%*2s from=%s case=%s dir=%s
  73.  ',win,find,repl,from0,uppr0,dirc0);
  74.  RETURN(UI_NUM("retn",0,result))
  75. }
  76.  
  77.  
  78. // start an ascii receive
  79. FUNC cmd_rcvasc(INT ses, STR file, INT line, INT ctrl, INT bit8)
  80. {
  81.  STR result;
  82.  
  83.  IF (!ses) { ses = WIN_FIND("","TERM") }
  84.  result = UI_CMD('
  85.     cmd=capt wind=%d file="%s" #save mode=%d ctrl=%d bit8=%d
  86.  ',ses,file,1+(line>0),(ctrl>0),(bit8>0));
  87.  RETURN(UI_NUM("retn",0,result));
  88. }
  89.  
  90.  
  91. // use uuundo to decode a file
  92. FUNC cmd_uuundo(STR file)
  93. {
  94.  INT run;
  95.  
  96.  run = IS_RUN("uuUN");
  97.  IF (!run) { F_LAUNCH(FN_TYPE("uuUN")) }
  98.  
  99.  UI_CMD('
  100.   cmd=apvt appl=@uuUN clas=@aevt kind=@odoc aeou="rqfi----file" file="%s"
  101.  ',file);
  102.  
  103.  IF (!run) { UI_CMD("cmd=apvt appl=@uuUN clas=@aevt kind=@quit") }
  104.  RETURN;
  105. }
  106.  
  107.  
  108. // send a file with ascii
  109. FUNC cmd_sndasc(INT ses, STR file, STR pmt, INT cp, INT lp, INT wid, INT blk)
  110. {
  111.  STR result;
  112.  STR cp0,lp0;
  113.  
  114.  IF (!IS_FILE(file)) { RETURN(0) }
  115.  IF (!ses) { ses = WIN_FIND("","TERM") }
  116.  
  117.  IF (IS_STR(cp)) { cp0 = cp }
  118.  IF (IS_NUM(cp)) { cp0 = STR_NUM(cp) }
  119.  IF (IS_STR(lp)) { lp0 = lp }
  120.  IF (IS_NUM(lp)) { lp0 = STR_NUM(lp) }
  121.  
  122.  result = UI_CMD('^
  123.  {onln cmd=session ptr=%d}
  124.  {from cmd=stream srcf="%s" +buf dstt=cmd conv=dot}
  125.  cmd=ascii strm=.from.strm sess=.onln.sess
  126.  prompt="%s" char="%s" line="%s" width=%d blank=%d"
  127.  ',ses,file,pmt,cp0,lp0,wid,(blk>0));
  128.  RETURN(UI_NUM("wind",0,result));
  129. }
  130.  
  131.  
  132. // tell finder to update folder
  133. FUNC cmd_osupdt(STR folder)
  134. {
  135.  RETURN(UI_NUM("retn",0,UI_CMD('
  136.   cmd=apvt appl=@MACS clas=@fndr kind=@fupd
  137.   aeou="rqfi----file" file="%s"
  138.   aein="opnuerrnerrn"
  139.  ',folder)));
  140. }
  141.  
  142.  
  143. // tell finder to clean-up folder/file
  144. FUNC cmd_osclean(STR folder)
  145. {
  146.  RETURN(UI_NUM("retn",0,UI_CMD('
  147.   cmd=apvt appl=@MACS clas=@fndr kind=@fclu
  148.   aeou="rqfi----file" file="%s"
  149.   aein="opnuerrnerrn"
  150.  ',folder)));
  151. }
  152.  
  153.  
  154. // disconnect from the service
  155. FUNC cmd_hang(INT ses)
  156. {
  157.  WT(0);
  158.  UI_CMD('
  159.   {onln cmd=sess ptr=%d}
  160.   cmd=online sess=.onln.sess opt=disc +status
  161.   {**** cmd=msg wind=%d msg=CLOS}
  162.  ',win,win);
  163.  RETURN(0);
  164. }
  165.  
  166.  
  167. // start another macro running (in its own thread space)
  168. FUNC cmd_macro(STR fname, INT ses)
  169. {
  170.  INT x;
  171.  INT win;
  172.  STR cli;
  173.  STR arg;
  174.  
  175.  // auto-decode of topmost session identifier
  176.  IF (ses == -1) {
  177.   ses = UI_NUM("sess",0,UI_CMD("cmd=session #find"));
  178.  }
  179.  
  180.  // build cli string for macro exec
  181.  cli = STR_FORMAT("cmd=macro file=&%*2s sess=%d", fname, ses);
  182.  x = 3;
  183.  WHILE (x <= ARGC()) {
  184.   arg = "";
  185.   IF (IS_NUM(ARGV(x))) {
  186.    arg = STR_FORMAT(" parm=%d", ARGV(x));
  187.   }
  188.   IF (IS_STR(ARGV(x))) {
  189.    arg = STR_FORMAT(" parm=&%*2s", ARGV(x));
  190.   }
  191.   cli = cli + arg;
  192.   x = x + 1;
  193.  }
  194.  
  195.  // start execing macro and return window ident
  196.  win = UI_NUM("wind",0,UI_CMD(cli));
  197.  RETURN(win);
  198. }
  199.